package gui.applets;
 
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Frame;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class AppletButtonB2 extends Applet{

	Button btn1=new Button("Button 1");
	Button btn2=new Button("Button 2");
	TextField tf=new TextField(20);
	
	public void init(){
		this.btn1.addActionListener(new Btn1());
		this.btn2.addActionListener(new Btn2());
		this.add(this.btn1);
		this.add(this.btn2);
		this.add(this.tf);
	}
	
	class Btn1 implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			tf.setText("Button 1");
		}
	}
	class Btn2 implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			tf.setText("Button 2");
		}
		
	}
	


	public static void main(String[]args){
		AppletButtonB applet=new AppletButtonB();
		Frame frame=new Frame("Button 1");
		
		//anonymity class 
		frame.addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent e){
				System.exit(0);
			}
		});
		frame.add(applet,BorderLayout.CENTER);
		frame.setSize(300,200);
		applet.init();
		applet.start();
		frame.setVisible(true);
	}
	
}
